package ClassWork5;

import java.util.ArrayList;
import java.util.List;

// 部门类
public class Dept {
    private String deptName;
    public List<Employee> employees = new ArrayList<>();

    public Dept(String deptName) {
        this.deptName = deptName;
    }

    public void addEmployee(Employee employee) {
        employees.add(employee);
    }

    public void removeEmployee(Employee employee) {
        employees.remove(employee);
    }

    public void transferEmployee(Employee employee, Dept newDept) {
        removeEmployee(employee);
        newDept.addEmployee(employee);
    }

    public String getDeptName() {
        return deptName;
    }
    // 新增方法用于判断员工是否在该部门
    public boolean containsEmployee(Employee employee) {
        return employees.contains(employee);
    }
}
